package com.ecoolex.hotel.saas.enums;

import java.time.Instant;
import java.util.Date;

import com.ecoolex.framework.common.EnumInterface;
import com.ecoolex.hotel.saas.entity.StoreAd;


public enum StoreAdStatus implements EnumInterface<StoreAdStatus, Integer> {
	RELEASE(1, "发布"),
	OFFLINE(2, "下线"),
	EXPIRED(3, "失效");

	private Integer real;

	private String describe;

	private StoreAdStatus(Integer real, String describe) {
		this.real = real;
		this.describe = describe;
	}

	@Override
	public Integer real() {
		return real;
	}

	@Override
	public String describe() {
		return describe;
	}
	
	public static boolean canDelete(StoreAd ad) {
	    return RELEASE.notEqual(ad.getStatus());
	}
	
	public static boolean canRelease(StoreAd ad) {
        return OFFLINE.equal(ad.getStatus()) && ad.getExpiryTime().after(Date.from(Instant.now()));
    }
	
	public static boolean canOffline(StoreAd ad) {
        return RELEASE.equal(ad.getStatus());
    }

}
